<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 构造函数
    function Father(money, cars, house, company) {
        this.money = money;
        this.cars = cars;
        this.house = house;
        this.company = company;

        // 管理方法
        this.manage = function (str) {
            return `管理方法: ${str}`;
        }
    }
    Father.prototype.manage2 = function (str) {
        return `管理方法2: ${str}`;
    }

    // 构造函数
    function Son(money, cars, house, company) {
        // 借调父构造函数的属性
        Father.call(this, money, cars, house, company);
    }

    // 改变原型指向
    // Son.prototype = new Father();
    Son.prototype = Object.create(Father.prototype);
    Son.prototype.constructor = Son;

    // 实例化
    son = new Son(100000, 10, 3, 'Inc');

    // 100000 10 3 'Inc' '管理方法: strict'
    console.log(son.money, son.cars, son.house, son.company, son.manage('strict'));

    // 语法糖类
    class Son2 extends Father {
        constructor(money, cars, house, company) {
            super(money, cars, house, company);
        }
    }

    // 实例化2
    son2 = new Son2(100000, 10, 3, 'Inc');

    // 100000 10 3 'Inc' '管理方法: strict'
    console.log(son2.money, son2.cars, son2.house, son2.company, son2.manage('strict'));

    console.dir(son);
    console.dir(son2);

</script>

</html>